/* 约数个数
* 1.N的约数个数(1~N中能整除N的个数 N%x == 0)
    N = p1^c1 * p2^c2 * p3^c3 * p4^c4... pk^ck
    f(N) = (c1+1) * (c2+2) * (c3+3) ... * (ck+k)

    1~N中 累加(1~N)f(i) O(NlogN)

    0 <= N <= 2e9 约数个数max <= 5e4

    for(int i = 1; i < N; i++){
        if(cnt[i] == 0) continue; //优化
        for(int j = i; j < N; j+=i)  //只考虑倍数 
            ans[j] += cnt[i];
    }

*/

#define DEBUG
#pragma GCC optimize("O1,O2,O3,Ofast")
#pragma GCC optimize("no-stack-protector,unroll-loops,fast-math,inline")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,ssse3")


#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 1e6+10;
int n;
int a[N], cnt[N], ans[N];

int main()
{
    #ifdef DEBUG
        freopen("./in.txt", "r", stdin);
    #else
        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #endif

    int n; cin >> n;
    
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        cnt[a[i]]++; //当前数的出现次数
    }

    for(int i = 1; i < N; i++){
        if(cnt[i] == 0) continue; //优化
        for(int j = i; j < N; j+=i)  //只考虑倍数 
            ans[j] += cnt[i];
    }
        

    for(int i = 0; i < n; i++)
        cout << ans[a[i]] - 1 << endl; //不考虑自己
    return 0;
}